#ifndef __BUILTIN_IMAGE_H__
#define __BUILTIN_IMAGE_H__
#include <stdint.h>
#include <cdefs.h>

#define BUILTIN_IMAGE(name, image)                              \
    extern uintptr_t _##name##_img_start;                        \
    extern uintptr_t _##name##_img_end;                          \
    asm(".pushsection .image_" __XSTRING(name) ", \"a\"\n\t"    \
    ".balign 64\n\t"                                            \
    ".global _" __XSTRING(name) "_img_start\n\t"                \
    "_" __XSTRING(name) "_img_start:\n\t"                       \
    ".incbin " __XSTRING(image) "\n\t"                          \
    ".global _" __XSTRING(name) "_img_end\n\t"                  \
    "_" __XSTRING(name) "_img_end:\n\t"                         \
    ".popsection");


#define IMAGE_ADDRESS(name) ((uintptr_t)&_##name##_img_start)
#define IMAGE_SIZE(name) ((size_t)&_##name##_img_end - (size_t)&_##name##_img_start)

#endif /* __BUILTIN_IMAGE_H__ */
